kind: VCDClusterConfiguration
apiVersions:
  - apiVersion: deckhouse.io/v1
    openAPISpec:
      type: object
      additionalProperties: false
      description: |
        Describes the configuration of a cloud cluster in VCD.

        Used by the cloud provider if a cluster's control plane is hosted in the cloud.

        Run the following command to change the configuration in a running cluster:

        ```shell
        kubectl -n d8-system exec -ti deploy/deckhouse -- deckhouse-controller edit provider-cluster-configuration
        ```
      x-doc-search: |
        ProviderClusterConfiguration
      x-examples:
        - apiVersion: deckhouse.io/v1
          kind: VCDClusterConfiguration
          sshPublicKey: "<SSH_PUBLIC_KEY>"
          organization: My_Org
          virtualDataCenter: My_Org
          virtualApplicationName: Cloud
          mainNetwork: internal
          layout: Standard
          internalNetworkCIDR: 172.16.2.0/24
          masterNodeGroup:
            replicas: 1
            instanceClass:
              template: Templates/ubuntu-focal-20.04
              sizingPolicy: 4cpu8ram
              rootDiskSizeGb: 20
              etcdDiskSizeGb: 20
              storageProfile: nvme
          nodeGroups:
            - name: worker
              replicas: 1
              instanceClass:
                template: Templates/ubuntu-focal-20.04
                sizingPolicy: 16cpu32ram
                storageProfile: ssd
          provider:
            server: '<SERVER>'
            username: '<USERNAME>'
            password: '<PASSWORD>'
            insecure: true
      required: [apiVersion, kind, masterNodeGroup, sshPublicKey, layout, provider, organization, virtualDataCenter, virtualApplicationName, mainNetwork]
      properties:
        apiVersion:
          type: string
          enum: [deckhouse.io/v1]
        kind:
          type: string
          enum: [VCDClusterConfiguration]
        masterNodeGroup:
          type: object
          additionalProperties: false
          required: [replicas, instanceClass]
          description: |
            The definition of the master's NodeGroup.

            > Caution! After changing the parameters of the section, you need to run `dhctl converge` for the changes to take effect.
          properties:
            replicas:
              type: integer
              minimum: 1
              description: |
                The number of master nodes to create. It is important to have an odd number of masters to ensure a quorum.
            instanceClass:
              type: object
              additionalProperties: false
              required: [template, storageProfile, sizingPolicy]
              description: |
                Partial contents of the fields of the [VCDInstanceClass](https://deckhouse.io/documentation/v1/modules/030-cloud-provider-VCD/cr.html#VCDinstanceclass).
              properties:
                rootDiskSizeGb:
                  description: |
                    root disk size in gigabytes.
                  example: 20
                  default: 20
                  type: integer
                etcdDiskSizeGb:
                  description: |
                    Etcd disk size in gigabytes.
                  example: 10
                  default: 10
                  type: integer
                placementPolicy:
                  description: |
                    PlacementPolicy is the placement policy to be used on this machine.
                    If no placement policy is specified, default placement policy will be used to create the nodes.
                  type: string
                  example: Hypervisor1
                sizingPolicy:
                  description: |
                    SizingPolicy is the sizing policy to be used on this machine.
                    If no sizing policy is specified, default sizing policy will be used to create the nodes.
                  type: string
                  example: 4Cpu8Memory
                storageProfile:
                  description: |
                    StorageProfile is the storage profile to be used on this machine.
                  type: string
                  example: ssd
                template:
                  description: |
                    Path of the template OVA that is to be used. Consists of catalog and template path.
                  type: string
                  example: Linux/ubuntu2204-cloud-ova
                mainNetworkIPAddresses:
                  type: array
                  description: |
                    A list of static IP addresses (with a CIDR prefix) sequentially allocated to nodes in the `mainNetwork`.

                    By default, the DHCP client is enabled.
                  x-examples:
                    - ["10.1.14.20", "10.1.4.21"]
                  items:
                    type: string
                    description: An IP address with a CIDR prefix.
                    pattern: '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'
        nodeGroups:
          type: array
          description: |
            An array of additional NodeGroups for creating static nodes (e.g., for dedicated front nodes or gateways).
          items:
            type: object
            required: [name, replicas, instanceClass]
            properties:
              name:
                type: string
                description: |
                  The name of the NodeGroup to use for generating node names.
              replicas:
                type: integer
                description: |
                  The number of nodes to create.
              nodeTemplate:
                description: |
                  Parameters of Node objects in Kubernetes to add after registering the node.
                properties:
                  labels:
                    type: object
                    description: |
                      A list of labels to attach to cluster resources.

                      The same as the `metadata.labels` standard [field](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#objectmeta-v1-meta).
                    x-examples:
                      - environment: production
                        app: warp-drive-ai
                    additionalProperties:
                      type: string
                  annotations:
                    type: object
                    description: |
                      The same as the `metadata.annotations` standard [field](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#objectmeta-v1-meta).
                    x-examples:
                      - ai.fleet.com/discombobulate: "true"
                    additionalProperties:
                      type: string
                  taints:
                    type: array
                    description: |
                      The same as the `.spec.taints` field of the [Node](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#taint-v1-core) object.

                      > **Caution!** Only the `effect`, `key`, `values`  fields are available.
                    x-examples:
                      - - effect: NoExecute
                          key: ship-class
                          value: frigate
                    items:
                      type: object
                      properties:
                        effect:
                          type: string
                          enum: [NoSchedule, PreferNoSchedule, NoExecute]
                        key:
                          type: string
                        value:
                          type: string
              instanceClass:
                type: object
                additionalProperties: false
                required: [template, storageProfile, sizingPolicy]
                description: |
                  Partial contents of the fields of the [VCDInstanceClass](https://deckhouse.io/documentation/v1/modules/030-cloud-provider-vcd/cr.html#VCDinstanceclass).
                properties:
                  rootDiskSizeGb:
                    description: |
                      root disk size in gigabytes.
                    example: 20
                    default: 20
                    type: integer
                  placementPolicy:
                    description: |
                      PlacementPolicy is the placement policy to be used on this machine.
                      If no placement policy is specified, default placement policy will be used to create the nodes.
                    type: string
                    example: Hypervisor1
                  sizingPolicy:
                    description: |
                      SizingPolicy is the sizing policy to be used on this machine.
                      If no sizing policy is specified, default sizing policy will be used to create the nodes.
                    type: string
                    example: 4Cpu8Memory
                  storageProfile:
                    description: |
                      StorageProfile is the storage profile to be used on this machine.
                    type: string
                    example: ssd
                  template:
                    description: |
                      Path of the template OVA that is to be used. Consists of catalog and template path.
                    type: string
                    example: Linux/ubuntu2204-cloud-ova
                  mainNetworkIPAddresses:
                    type: array
                    description: |
                      A list of static IP addresses (with a CIDR prefix) sequentially allocated to nodes in the `mainNetwork`.

                      By default, the DHCP client is enabled.
                    x-examples:
                      - ["10.1.14.20", "10.1.4.21"]
                    items:
                      type: string
                      description: An IP address with a CIDR prefix.
                      pattern: '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'
        sshPublicKey:
          type: string
          description: |
            A public key for accessing nodes.
        organization:
          type: string
          description: |
            Vcloud Director Organization name.
        virtualDataCenter:
          type: string
          description: |
            Vcloud Director Virtual Data Center name (belongs to Organization).
        virtualApplicationName:
          type: string
          # cluster api getting app by VCDCluster name and we should create app with kubernetes resources name restrictions
          # base on this answer https://stackoverflow.com/a/67387967
          pattern: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?$'
          description: |
            Vcloud Director Virtual Application name (belongs to Virtual Data Center).
        mainNetwork:
          description: |
            Path to the network that VirtualMachines' primary NICs will connect to (default gateway).
          example: internal
          type: string
        internalNetworkCIDR:
          type: string
          description: |
            Subnet for master nodes in the internal network.

            Addresses are allocated starting with the tenth address. E.g., if you have the `192.168.199.0/24` subnet, addresses will be allocated starting with `192.168.199.10`.
          pattern: '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(3[0-2]|[1-2][0-9]|[0-9]))$'
        layout:
          type: string
          description: |
            The way resources are located in the cloud.

            Read [more](https://deckhouse.io/documentation/v1/modules/030-cloud-provider-vcd/layouts.html) about possible provider layouts.
        provider:
          type: object
          additionalProperties: false
          description: Parameters for connecting to the VCD.
          properties:
            server:
              type: string
              description: The host or the IP address of the VCD server.
            username:
              type: string
              description: The login ID.
            password:
              type: string
              description: The user's password.
            insecure:
              type: boolean
              description:  Set to `true` if VCD has a self-signed certificate.
              x-doc-default: false
          required:
            - server
            - username
            - password
      oneOf:
        - required: [layout]
          properties:
            layout:
              enum:
                - Standard
              type: string
